import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_lang/flutter_lang.dart';
import 'package:oktoast/oktoast.dart';
import 'package:wallet_home/page/theme/colors.dart';
import 'package:wallet_home/tools/theme_utils.dart';
import 'package:wallet_home/module_config.dart';

class ExportPrivateKeyPage extends StatefulWidget {
  final String privateKey;

  const ExportPrivateKeyPage({Key key, @required this.privateKey})
      : super(key: key);

  @override
  _ExportPrivateKeyPageState createState() => _ExportPrivateKeyPageState();
}

class _ExportPrivateKeyPageState extends State<ExportPrivateKeyPage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        elevation: 0,
        brightness: Brightness.dark,
        title: Text(
          "${WXLang.$t("home_export_private_key",package: ModuleConfig.moduleName)}",
          style: TextStyle(
              color: ThemeUtils.getThemeColor(
                  context: context,
                  brightnessColor: Colors.white,
                  darkColor: Colors.grey[200])),
        ),
        leading: IconButton(
          icon: Icon(
            Icons.arrow_back,
            color: ThemeUtils.getThemeColor(
                context: context,
                brightnessColor: Colors.white,
                darkColor: Colors.grey[200]),
          ),
          onPressed: () {
            Navigator.of(context).pop();
          },
        ),
      ),
      body: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Container(
              margin: EdgeInsets.fromLTRB(25, 15, 25, 0),
              child: Text(
                "${WXLang.$t("home_security_save_warning",package: ModuleConfig.moduleName)}",
                style: TextStyle(
                  fontSize: 14,
                  color: ThemeUtils.getThemeColor(
                      context: context,
                      brightnessColor: Colors.grey[600],
                      darkColor: Colors.white),
                ),
              ),
            ),
            Container(
              margin: EdgeInsets.fromLTRB(25, 15, 25, 0),
              child: Text(
                "${WXLang.$t("home_transport_safe_warning",package: ModuleConfig.moduleName)}",
                style: TextStyle(
                  fontSize: 14,
                  color: ThemeUtils.getThemeColor(
                      context: context,
                      brightnessColor: Colors.grey[600],
                      darkColor: Colors.white),
                ),
              ),
            ),
            Container(
              margin: EdgeInsets.fromLTRB(40, 70, 40, 0),
              child: Text(
                "${widget.privateKey}",
                style: TextStyle(
                  fontSize: 15,
                  color: ThemeUtils.getThemeColor(
                      context: context,
                      brightnessColor: Colors.grey[600],
                      darkColor: Colors.white),
                ),
              ),
            ),

            Container(
              margin: EdgeInsets.fromLTRB(0, 50, 0, 0),
              child: Center(
                child: MaterialButton(
                  color: Colours.app_main,
                  child: Text("${WXLang.$t("home_copy_private_key",package: ModuleConfig.moduleName)}",style: TextStyle(color: Colors.white),),
                  onPressed: () {
                    Clipboard.setData(ClipboardData(text: "${widget.privateKey}"));
                    showToast("${WXLang.$t("home_copy_text_prompt",package: ModuleConfig.moduleName)}");
                  },
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
